package com.example.sentinel.consumer.controller;

import com.example.sentinel.common.bean.Result;
import com.example.sentinel.consumer.feign.ProviderClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 消费者控制器
 *
 * @author beerus
 * @date 2020/6/14 18:00
 */
@RestController
@RequestMapping(value = "/consumer")
public class ConsumerController {

    /**
     * 消费者
     */
    @Resource
    private ProviderClient providerClient;

    @GetMapping("/hello")
    public Result hello() {
        return Result.success("hello 成功了！");
    }

    @GetMapping("/test")
    public Result testProvider() {
        // 发起远程调用
        String userName = providerClient.getUserName();
        return Result.success(userName);
    }

}
